
layui.use(['layer', 'form'], function(){
    var table = layui.table;
    var $=layui.$;

    var t=table.render({
        elem: '#data' //指定原始表格元素选择器（推荐id选择器）
        ,url:'/mywechat/getprice'
        ,method:'post'
        ,contentType: 'application/json'
        ,cols: [
            [
                {field:'productNum',title:'货号',width: '15%'},
                {field:'productName',title:'名称',width:'30%'},
                {field:'categoryName',title:'分类名称',width:'20%',sort:true},
                {field:'width',title:'门幅'},
                {field:'material',title:'成分'},
                {field:'priceSale',title:'今日参考'},
            ]
        ],
        page:{limit:20}
    });


    function reload(){
        t.reload({
            where:{
                productName:$("#search").val(),
                productNum:$("#search").val(),
                categoryName:$("#search").val()
            },
            page:{
                curr:1
            }
        })
    }

    $("#submit").click(function (){
        reload();

    })

    $("#clear").click(function (){
        $("#search").val("");
        reload();
    })

});